{# ----------------------------------------------------------------------------
 # SymForce - Copyright 2022, Skydio, Inc.
 # This source code is under the Apache 2.0 license found in the LICENSE file.
 # ---------------------------------------------------------------------------- #}

{%- import "./util.jinja" as util with context -%}

package {{ name }};
{% for typename in types_to_generate %}

struct {{ typename }} {
  {% set info = types_dict[typename] -%}
  {% for key, entry in info['index'].items() %}
    {% set datatype = entry.datatype() %}
    {% if issubclass(datatype, Values) %}
  {{ info['subtypes'][key] }} {{ key }};
    {% elif issubclass(datatype, T.Scalar) %}
  {{ scalar_type }} {{ key }};
    {% elif issubclass(datatype, (list, tuple)) %}
      {% if key in info['subtypes'].keys() %}
  {{ info['subtypes'][key] }} {{ key }}{{ util.get_list_dims(entry.item_index) }};
      {% else %}
  {{ util.get_list_type(scalar_type, entry.item_index) }} {{ key }}{{ util.get_list_dims(entry.item_index) }};
      {% endif %}
    {% elif issubclass(datatype, DataBuffer)%}
  int64_t {{ key }};
    {% else %}
      {% if not use_eigen_types %}
  {{ scalar_type }} {{ key }}[{{ info['storage_dims'][key] }}];
      {% else %}
  {{ util.eigen_lcm_type(scalar_type, info['storage_dims'][key], info["index"][key]["shape"]) }} {{ key }};
      {% endif %}
    {% endif %}
  {% endfor %}
}
{% endfor %}
